import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
  BwCustomComSlotParamDataTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'activeKey',
    name: '当前激活 tab 面板的 key',
    isModel: true,
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'animated',
    name: '是否使用动画切换',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'centered',
    name: '标签居中展示',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'destroyInactiveTabPane',
    name: '被隐藏时是否销毁 DOM 结构',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'hideAdd',
    name: '是否隐藏加号图标',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'size',
    name: '大小，提供 large middle 和 small 三种大小',
    isRequire: false,
    defaultValue: 'middle',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '大号',
          value: 'large',
        },
        {
          label: '中等',
          value: 'middle',
        },
        {
          label: '小号',
          value: 'small',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'tabBarGutter',
    name: 'tabs 之间的间隙',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.number],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'tabBarStyle',
    name: 'tab bar 的样式对象',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'tabPosition',
    name: '页签位置，可选值有 top right bottom left',
    isRequire: false,
    defaultValue: 'top',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: 'top',
          value: 'top',
        },
        {
          label: 'right',
          value: 'right',
        },
        {
          label: 'bottom',
          value: 'bottom',
        },
        {
          label: 'left',
          value: 'left',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'type',
    name: '页签的基本样式，可选 line、card editable-card 类型',
    isRequire: false,
    defaultValue: 'line',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: 'line',
          value: 'line',
        },
        {
          label: 'card',
          value: 'card',
        },
        {
          label: 'editable-card',
          value: 'editable-card',
        },
      ],
    }),
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:activeKey',
    name: '更新绑定值',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: 'value',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'change',
    name: '切换面板的回调',
    params: [
      {
        paramKey: 'activeKey',
        paramName: 'activeKey',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'edit',
    name: '新增和删除页签的回调，在 type="editable-card" 时有效',
    params: [
      {
        paramKey: 'event',
        paramName: 'event',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
      {
        paramKey: 'action',
        paramName: 'action',
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
  {
    key: 'tabClick',
    name: 'tab 被点击的回调',
    params: [],
  },
  {
    key: 'tabScroll',
    name: '滚动 TabBar 时触发',
    params: [
      {
        paramKey: 'direction',
        paramName: '方向', // left right top bottom
        paramDataType: BwCustomComEmitParamDataTypeEnum.string,
        remark: '',
      },
    ],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'default',
      slotName: '默认插槽',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'addIcon',
      slotName: '自定义添加按钮',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'leftExtra',
      slotName: 'tab bar 上左侧额外的元素',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'moreIcon',
      slotName: '自定义折叠 icon',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'renderTabBar',
      slotName: '替换 TabBar，用于二次封装标签头',
      slotParams: [
        {
          paramKey: 'params',
          paramName: '插槽参数',
          paramDataType: BwCustomComSlotParamDataTypeEnum.object,
          remark: '',
        },
      ],
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'rightExtra',
      slotName: 'tab bar 上右侧额外的元素',
    },
  },
]

export const antTabsInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
